<?php


/*   Description  of this file
*    Author king-of-war
*    Last Modified 2009-5-3
*    This class designed  for the count_cfg operation
*/
class count_cfg {

	private $url;

	function __construct($url) {
		/*
		 * init the conn class
		*/
		include_once $url . 'includes/conn.php';
		include_once $url . 'admin/class/error.class.php';
		include_once $url . 'includes/entity/count_cfg.entity.php';
		$this->set_url($url);
	}

	/*
	 *  count_cfg data get
	 */
	function count_cfg_get() {
		$cfg = new count_cfg_entity();
		$conn = new conn();
		$sql = "select * from count_cfg";
		$conn->set_sql($sql);
		$line = $conn->get_line();
		if ($line) {
			$result = $conn->get_result();
			$row = $result->fetch_row();
			if (!empty ($row)) {
				$cfg->set_start($row[0]);
				$cfg->set_temp($row[1]);
				$cfg->set_time($row[2]);
			} else {
				$info = 'Null result';
				$error->error_chinese($info);

			}
		} else {
			$info = 'could not get count_cfg data<br> please make sure the data were correct you input<br> or send this message to administrator';
			$error->error_chinese($info);
		}
		return $cfg;
	}

	/*
	 * define  update count_cft
	 */

	function count_cfg_update($start, $temp, $time) {
		$conn = new conn();
		$sql = sprintf("update count_cfg set start='%d',temp='%d',time='%d' ", $start, $temp, $time);
		$conn->set_sql($sql);
		$line = $conn->get_line();
		return $line;
	}

	/*
	 *  common function of count config
	 */
	function set_url($url) {
		$this->url = $url;
	}

	function get_url() {
		return $this->url;
	}

}
?>